import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:part_time_job_pro/common/cache/app_box.dart';
import 'package:part_time_job_pro/common/style/color.dart';
import 'package:part_time_job_pro/gen/assets.gen.dart';

class CustomAppBar {
  static Scaffold standardScaffold({String title = "", Color? backgroundColor, required Widget body}) {
    return Scaffold(
      appBar: CustomAppBar.customAppBar(title: title),
      backgroundColor: backgroundColor ?? const Color(0xFFFFFFFF),
      body: body,
    );
  }

  static AppBar customAppBar({
    String title = "",
    Widget? titleWidget,
    PreferredSizeWidget? bottom,
    bool hasLeading = true,
    Color backgroundColor = Colors.white,
    Widget? leading,
    Widget? actions,
  }) {
    return AppBar(
      systemOverlayStyle: SystemUiOverlayStyle.dark,
      leading: hasLeading
          ? (leading ??
                InkWell(
                  onTap: () {
                    Get.back();
                  },
                  child: CustomAppBar.backIcon(),
                ))
          : null,
      actions: [actions ?? InkWell(onTap: () {}, child: Container())],
      leadingWidth: 65.w,
      title:
          titleWidget ??
          CustomAppBar.appBarTitle(title: title, color: AppBox.shared.theme == 2 ? Colors.white : AppColor.black333333),
      backgroundColor: AppBox.shared.theme == 2 ? Colors.black : backgroundColor,
      forceMaterialTransparency: true,
      elevation: 0,
      centerTitle: true,
      bottom: bottom,
    );
  }

  static Widget backIcon() {
    return MyAssets.images.icon.back.image(width: 18.w, height: 18.w, color: AppColor.black333333);
  }

  static Widget appBarTitle({String title = "", Color color = AppColor.black333333}) {
    return Text(
      title,
      style: TextStyle(fontSize: 18.sp, color: color, fontWeight: FontWeight.w500),
    );
  }
}
